<?php
$access = $obj->access;
if(!empty($obj->result)){ ?>
<form action="/admin/addgroup.html" method="POST">
	<table border='0' cellspacing='0' cellpadding='0'>
		<tr>
			<td width="180px" style="padding:10px 0 0 20px;">Назва <font color='red' size="3px">*</font>:</td>
			<td width="700px"><input name='name' type="text" style="width:350px;" /></td>
		</tr>
		<tr>
			<td width="180px" style="padding:10px 0 0 20px;">Доступ до адмін панелі <font color='red' size="3px">*</font>:</td>
			<td width="700px" style="padding-top:12px;"><input name='cpanel' onclick="if(this.checked){document.getElementById('Permissions').style.display='block';}else{document.getElementById('Permissions').style.display='none';}" type="checkbox" value="1"/></td>
		</tr>
                <tr>
                    <td colspan="2" style="padding:10px 0 0 20px;">
                        <fieldset id="Permissions" style="display:none;">
			<legend>Права доступу</legend>
                                <table border='1' cellpadding="0" cellspacing="0">
                                    <tr>
                                            <td width="300px" class="title">Назва</td>
                                            <td width="150px" class="title">Права</td>
                                    </tr>
                                    <?php foreach($obj->result as $key=>$value){ ?>
                                    <tr id="<?php echo $value['modul']; ?>" <?php if($value['modul']=='GROUPS'){echo"style='display:none;'";} ?>>
                                            <td style="font-size:14px;padding-top:7px;"><?php echo $key;?>:</td>
                                            <td>
                                                    <select name="<?php echo $value['modul']; ?>" style="width:150px;">
                                                        <?php $super=NULL; foreach($value as $type){
                                                            if(strlen($type['type'])<=1)continue;
                                                            if($value['modul']=='USERS' && $type['mod']>=5 && $access['allow_super']!=true)continue;
                                                            if($type['mod']>=5 && $value['modul']=='USERS'){$super="onclick=\"if(this.selected){jQuery('#GROUPS').attr('style', '');}\"";}
                                                            elseif($type['mod']<=4 && $value['modul']=='USERS'){$super="onclick=\"if(this.selected){jQuery('#GROUPS').attr('style', 'display:none;');}\"";}
                                                            echo"<option value='".$type['mod']."' ".$super.">".$type['type']."</option>";
                                                       } ?>
                                                    </select>
                                            </td>
                                    </tr>
                                    <?php } ?>
                                </table>

			</fieldset>
                    </td>
                </tr>
		<tr><td  style="padding:10px 0 0 20px;" colspan="2">
			<input class="button" type="submit" value="Додати"/>
			</td>
		</tr>
	</table>
</form>
<?php } ?>
<div style="padding:10px 0 0 20px;color:<?php echo $obj->status['color']; ?>;font-size:14px;"><?php echo $obj->status['content']; ?></div>
